<extend name="Public/Info/Common"/>
<block name="pageContent">
    <div class="bjui-pageContent">
        <!-- 表单 -->
        <form id="form" action="{:U('update')}" data-toggle="validate" method="post" class="pageForm">
            <input type="hidden" name="id" value="{:I('get.id')}">
            <input type="hidden" name="model_id" value="{:I('get.model_id')}">
            <ul class="nav nav-tabs" role="tablist">
                <li class="active"><a href="#Attribute{$info.id}base" role="tab" data-toggle="tab">基 础</a></li>
                <li><a href="#Attribute{$info.id}expert" role="tab" data-toggle="tab">高 级</a></li>
            </ul>
            <div class="tab-content">
                <!-- 基础 -->
                <div id="Attribute{$info.id}base" class="tab-pane active in">
                    <div class="form-item cf">
                        <label class="item-label">字段名<span class="check-tips">（请输入字段名 英文字母开头，长度不超过30）</span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="name" value="{$info.name}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">字段标题<span class="check-tips">（请输入字段标题，用于表单显示）</span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="title" value="{$info.title}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">字段类型<span class="check-tips">（用于表单中的展示方式）</span></label>
                        <div class="controls">
                            <select name="type" id="data-type">
                                <option value="">----请选择----</option>
                                <volist name=":get_attribute_type()" id="type">
                                    <option value="{$key}" rule="{$type[1]}" <if condition="$key==$info['type']"> selected </if>>{$type[0]}</option>
                                </volist>
                            </select>
                            是否自动更新字段<input type="checkbox" id="AutoAttribute" checked>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">字段定义<span class="check-tips">（字段属性的sql表示）</span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="field" value="{$info.field}"
                                   id="data-field">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">参数<span class="check-tips">（布尔、枚举、多选字段类型的定义数据）</span></label>

                        <div class="controls">
                            <label class="textarea input-large">
                                <textarea name="extra">{$info.extra}</textarea>
                            </label>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">默认值<span class="check-tips">（字段的默认值）</span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="value" value="{$info.value}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">字段备注<span class="check-tips">(用于表单中的提示)</span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="remark" value="{$info.remark}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">是否显示<span class="check-tips">（是否显示在表单中）</span></label>

                        <div class="controls">
                            <select name="is_show">
                                <option value="1">始终显示</option>
                                <option value="2">新增显示</option>
                                <option value="3">编辑显示</option>
                                <option value="0">不显示</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">是否必填<span class="check-tips">（用于自动验证）</span></label>

                        <div class="controls">
                            <select name="is_must">
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                        </div>
                    </div>
                </div>
                <!-- 高级 -->
                <div id="Attribute{$info.id}expert" class="tab-pane">
                    <div class="form-item cf">
                        <label class="item-label">验证方式<span class="check-tips"></span></label>

                        <div class="controls">
                            <select name="validate_type">
                                <option value="regex">正则验证</option>
                                <option value="function">函数验证</option>
                                <option value="unique">唯一验证</option>
                                <option value="length">长度验证</option>
                                <option value="in">验证在范围内</option>
                                <option value="notin">验证不在范围内</option>
                                <option value="between">区间验证</option>
                                <option value="notbetween">不在区间验证</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">验证规则<span class="check-tips">（根据验证方式定义相关验证规则）</span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="validate_rule"
                                   value="{$info.validate_rule}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">出错提示<span class="check-tips"></span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="error_info" value="{$info.error_info}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">验证时间<span class="check-tips"></span></label>

                        <div class="controls">
                            <select name="validate_time">
                                <option value="3">始 终</option>
                                <option value="1">新 增</option>
                                <option value="2">编 辑</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">自动完成方式<span class="check-tips"></span></label>

                        <div class="controls">
                            <select name="auto_type">
                                <option value="function">函数</option>
                                <option value="field">字段</option>
                                <option value="string">字符串</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">自动完成规则<span class="check-tips">（根据完成方式订阅相关规则）</span></label>

                        <div class="controls">
                            <input type="text" class="text input-large" name="auto_rule" value="{$info.auto_rule}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">自动完成时间<span class="check-tips"></span></label>

                        <div class="controls">
                            <select name="auto_time">
                                <option value="3">始 终</option>
                                <option value="1">新 增</option>
                                <option value="2">编 辑</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</block>
<block name="pageJavascript">
    <script type="text/javascript" charset="utf-8">
        $.CurrentDialog.find('#data-type').change(function () {
            if($.CurrentDialog.find('#AutoAttribute:checked').length){
                $.CurrentDialog.find('#data-field').val($(this).find('option:selected').attr('rule'));
            }
        });
    </script>
</block>

